Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@metamask/utils

Package Overview
Dependencies
Maintainers
9
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@metamask/utils

Various JavaScript/TypeScript utilities of wide relevance to the MetaMask codebase

  • 6.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
422K
decreased by-40.34%
Maintainers
9
Weekly downloads
 
Created

What is @metamask/utils?

@metamask/utils is a utility library provided by MetaMask that offers a variety of helper functions and utilities to facilitate Ethereum and blockchain development. It includes functions for handling Ethereum addresses, hex strings, and other common tasks in the Ethereum ecosystem.

What are @metamask/utils's main functionalities?

Hex String Utilities

This feature provides utilities for working with hex strings, such as checking if a string is a valid hex string and converting hex strings to UTF-8.

const { isHexString, hexToUtf8 } = require('@metamask/utils');

const hex = '0x68656c6c6f';
console.log(isHexString(hex)); // true
console.log(hexToUtf8(hex)); // 'hello'

Ethereum Address Utilities

This feature includes functions for validating Ethereum addresses and converting them to checksum addresses.

const { isValidAddress, toChecksumAddress } = require('@metamask/utils');

const address = '0x742d35Cc6634C0532925a3b844Bc454e4438f44e';
console.log(isValidAddress(address)); // true
console.log(toChecksumAddress(address)); // '0x742d35Cc6634C0532925a3b844Bc454e4438f44e'

Type Conversion Utilities

This feature provides utilities for converting between different types, such as numbers and hex strings.

const { numberToHex, hexToNumber } = require('@metamask/utils');

const number = 12345;
const hex = numberToHex(number);
console.log(hex); // '0x3039'
console.log(hexToNumber(hex)); // 12345

Other packages similar to @metamask/utils

FAQs

Package last updated on 11 Jul 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc